package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.CompanyRoyaltyRequest;
import one.stand.request.CompanyTransferRequest;
import one.stand.request.OrdersRequest;
import one.stand.request.RoyaltyRecordRequest;
import one.stand.response.OrdersResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 分销管理
 * @author
 */
@RestController
@RequestMapping("crmPc/distribution")
@Api(tags="分销管理")
public class DistributionController extends BaseController {

    @PostMapping("/getRoyaltyData")
    @ApiOperation(value = "分销管理-数据统计")
    @ApiController(isLogin = true,company = true,card = true,paramClass = RoyaltyRecordRequest.class )
    public ResultModel<Map<String, Object>> getRoyaltyData(@RequestAttribute RoyaltyRecordRequest request) {
        return crmFegin.getRoyaltyData(request);
    }

    @PostMapping("/companyRoyalty")
    @ApiOperation(value = "设置分销金额比例")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "level", value = "提成等级", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "royaltyRatio", value = "提成比例", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = CompanyRoyaltyRequest.class )
    public ResultModel<Boolean> companyRoyalty(@RequestAttribute CompanyRoyaltyRequest request) {
        return crmFegin.companyRoyalty(request);
    }

    @PostMapping("/insertCompanyRoyalty")
    @ApiOperation(value = "设置分销金额比例 (3.2版本迭代)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "royaltyId", value = "比例id", paramType = "Integer"),
            @ApiImplicitParam(name = "level", value = "分销等级（1初级分销员，2中级分销员，3钻石分销员）", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "conditions", value = "满足条件", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "oneRoyalty", value = "一级提成", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "twoRoyalty", value = "二级提成", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = CompanyRoyaltyRequest.class )
    public ResultModel<Boolean> insertCompanyRoyalty(@RequestAttribute CompanyRoyaltyRequest request) {
        return crmFegin.insertCompanyRoyalty(request);
    }

    @PostMapping("/selectRoyaltyOrderList")
    @ApiOperation(value = "分销订单列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderState", value = "订单状态（1待付款，2待发货，3待收货，4已完成，5交易取消，6退款成功）", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass =OrdersRequest.class )
    public ResultModel<Map<String, Object>> selectRoyaltyOrderList(@RequestAttribute OrdersRequest request) {
        return crmFegin.selectRoyaltyOrderList(request);
    }

    @PostMapping("/getRoyaltyOrderInfo")
    @ApiOperation(value = "分销订单详情")
    @ApiController(isLogin = true,company = true,card = true,paramClass =OrdersRequest.class )
    public ResultModel<Map<String, Object>> getRoyaltyOrderInfo(@RequestAttribute OrdersRequest request) {
        return crmFegin.getRoyaltyOrderInfo(request);
    }

    @PostMapping("/selectRoyaltyRankList")
    @ApiOperation(value = "佣金排行列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateType", value = "1总金额排名 2本月佣金排名 3上月佣金排名", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass =RoyaltyRecordRequest.class )
    public ResultModel<Map<String, Object>> selectRoyaltyRankList(@RequestAttribute RoyaltyRecordRequest request) {
        return crmFegin.selectRoyaltyRankList(request);
    }

    @ApiOperation(value = "企业到账记录列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "state", value = "0失败1线上提现成功2线下交易", paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass =CompanyTransferRequest.class )
    @PostMapping("/selectCompanyTransferList")
    public ResultModel<Map<String, Object>> selectCompanyTransferList(@RequestAttribute CompanyTransferRequest request) {
        return crmFegin.selectCompanyTransferList(request);
    }

    @ApiOperation(value = "更改企业到账记录结算状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "transferId", value = "公司转账id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass =CompanyTransferRequest.class )
    @PostMapping("/updateCompanyTransferState")
    public ResultModel<Boolean> updateCompanyTransferState(@RequestAttribute CompanyTransferRequest request) {
        return crmFegin.updateCompanyTransferState(request);
    }

    @ApiOperation(value = "更改佣金列表结算状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "recordId", value = "记录id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass =RoyaltyRecordRequest.class )
    @PostMapping("/updateRoyaltyRecordState")
    public ResultModel<Boolean> updateRoyaltyRecordState(@RequestAttribute RoyaltyRecordRequest request) {
        return crmFegin.updateRoyaltyRecordState(request);
    }

}
